package awd.bj.jls.webs.api.hystrix;

import awd.bj.jls.webs.api.LogsApi;
import awd.bj.jls.webs.utils.ResponseMessage;
import awd.bj.logs.model.OperatelogsModel;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class LogsApiFallBackFactory implements FallbackFactory<LogsApi> {

    Logger logger = LoggerFactory.getLogger(LogsApi.class);

    @Override
    public LogsApi create(Throwable cause) {
        return new LogsApi() {
            @Override
            public ResponseMessage<String> operatelogsSave(OperatelogsModel operatelogs) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }
        };
    }
}
